package com.example.itemtouchhelper

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * @author by liliang on 2020/6/2 3:58 AM
 */
class LinearLayoutItemDecoration : RecyclerView.ItemDecoration(){

    companion object {
        private const val DEFAULT_OFFSET = 10
    }

    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        val adapterPosition = parent.getChildViewHolder(view).adapterPosition
        if (adapterPosition == parent.adapter!!.itemCount - 1) {
            outRect.set(0, 0, 0, 0);
        } else {
            outRect.set(0, 0, 0, Companion.DEFAULT_OFFSET);
        }
    }


}